package huixue.cn.com.rxapp.service;

import android.app.Service;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;

import huixue.cn.com.library.util.LogUtils;

public class ComputeService extends Service {

    public ComputeService() {

    }

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    public IBinder mBinder = new Binder(){
        @Override
        protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
            //return super.onTransact(code, data, reply, flags);
            if (code == 1) {
                String _arg0 = data.readString();
                String _arg1 = data.readString();
                String _result = this.strcat(_arg0, _arg1);
                reply.writeString(_result);
                return true;
            }
            return super.onTransact(code, data, reply, flags);
        }

        public String strcat(String x, String y){
            return x + y;
        }
    };

    @Override
    public void unbindService(ServiceConnection conn) {
        super.unbindService(conn);
        LogUtils.e("==ComputeService==unbindService");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        LogUtils.e("==ComputeService==onCreate");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        LogUtils.e("==ComputeService==onStartCommand");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        LogUtils.e("==ComputeService==onDestroy");
    }



    /*@Override
    public void unbindService(ServiceConnection conn) {
        super.unbindService(conn);
        LogUtils.e("==ComputeService==unbindService");
    }

    @Override
    public boolean bindService(Intent service, ServiceConnection conn, int flags) {
        LogUtils.e("==ComputeService==bindService");
        return super.bindService(service, conn, flags);
    }*/

}
